home *** CD-ROM | disk | FTP | other *** search
/ Aminet 6 / Aminet 6 - June 1995.iso / Aminet / dev / src / hz.lha / Hz / Hz.asm next >
Encoding:
Assembly Source File  |  1995-03-30  |  2.0 KB  |  81 lines

  1. ;
  2. ; Hz   An extremely simple PAL/NTSC
  3. ;      tool.  Designed for fast and
  4. ;      easy display changing for use
  5. ;      when developing PAL/NTSC
  6. ;      adjusting applications.
  7. ;
  8. ; An simple example for new assembly language programmers.
  9. ; Written by Christopher Jennings.
  10. ;
  11. ; Copyright © 1993 by Enchanted Blade Associates.
  12. ; All rights reserved.  Freely distributable without
  13. ; modifications.  Permission granted to use for
  14. ; commercial purposes or within commercial products,
  15. ; but please give credit for the author's work.
  16. ;
  17.  
  18. openlib  equ -552
  19. closelib equ -414
  20. output   equ -60
  21. write    equ -48
  22.  
  23. nextletter              ; Extremely simplified "command line parsing"
  24.    cmpi.b #'?',(a0)     ; Is it a '?'?
  25.    beq.s  help
  26.    cmpi.b #'p',(a0)     ; Is it a 'p'?
  27.    beq.s  pal
  28.    cmpi.b #'P',(a0)     ; Is it a 'P'?
  29.    beq.s  pal
  30.    cmpi.b #'n',(a0)     ; Is it an 'n'?
  31.    beq.s  ntsc
  32.    cmpi.b #'N',(a0)     ; Is it an 'N'?
  33.    beq.s  ntsc
  34.    cmpi.b #10,(a0)+     ; Is it an EOL? Move argument to next letter
  35.    bne.s  nextletter
  36. ntsc
  37.    move.w #0,$dff1dc    ; Switch to NTSC
  38.    moveq  #0,d0
  39.    rts
  40. pal
  41.    move.w #32,$dff1dc   ; Switch to PAL
  42.    moveq  #0,d0
  43.    rts
  44. help
  45.    movem.l a6/d2-d3,-(sp) ; Save the non-scratch registers we use
  46.    lea     dosname(pc),a1 ; Open any dos lib
  47.    moveq   #0,d0
  48.    movea.l 4,a6
  49.    jsr     openlib(a6)
  50.    tst.l   d0
  51.    beq.s   nolib
  52.    movea.l d0,a6          ; Switch to dos to get our handle
  53.    jsr     output(a6)
  54.    move.l  d0,d1
  55.    beq.s   nohandle
  56.    lea     usage(pc),a0   ; Address of length+message
  57.    moveq   #0,d3          ; Clear upper 24 bits
  58.    move.b  (a0)+,d3       ; Get length
  59.    move.l  a0,d2          ; Get address
  60.    jsr     write(a6)
  61. nohandle
  62.    movea.l a6,a1          ; Close dos lib
  63.    movea.l 4,a6
  64.    jsr     closelib(a6)
  65. nolib
  66.    movem.l (sp)+,a6/d2-d3 ; Restore registers
  67.    moveq   #0,d0          ; Error-free exit
  68.    rts
  69.  
  70. usage
  71.       dc.b dosname-usage-1
  72.       dc.b 10
  73.       dc.b 'USAGE: Hz [N=NTSC|P=PAL|?]',10
  74.       dc.b 'Default action is NTSC',10
  75.       dc.b 10
  76. dosname
  77.       dc.b 'dos.library',0
  78.  
  79. ; Yup. That's it.
  80.  
  81.